<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('s', ''); ?>
<div class="menu_list list-items">
    <table style="clear:both;" id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
        <thead class="fields">
			<tr>
				<th class="first" style="text-align:center;">&nbsp;&nbsp;#&nbsp;&nbsp;</th>
				<th><?php echo ucfirst($txt->getWord('image')); ?></th>
				<th><?php echo ucfirst($txt->getWord('order')); ?></th>
				<th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
			</tr>
			<tr class="items">
                <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                                class="icon command" 
                                                src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                                onclick="edit_form.submit();" /></td>
                <td><input class="medium" type="file" name="Image" /></td>
				<td>&nbsp;</td>
                <td class="last"></td>
            </tr>
		</thead>
		<tbody>
			<?php 
			if($adc->CurrentAd->getImages()): ?>
				<?php 
				$thsize = '';
				if(count($thumb['ADS']) > 1)
				{ $thsize = $thumb['ADS'][(count($thumb['ADS'])-1)]['MAXW'].'_'; }
				foreach($adc->CurrentAd->getImages() as $primage): ?>
				<tr>
				<td class="first">&nbsp;&nbsp;<?php echo ($primage->getimageOrder()+1); ?>&nbsp;&nbsp;<input type="hidden" name="img_id[]" value="<?php echo $primage->getId(); ?>" /></td>
				<td>&nbsp;&nbsp;<?php echo '<a href="'.ADS_URL.$primage->getFilename().'" target="_blank"><img src="'.ADS_URL.'thumbs/'.$thsize.$primage->getFilename().'" /></a>'; ?>&nbsp;&nbsp;</td>
				<td class="center">
                    <?php echo $commander->getCommandButton('up', $primage->getId()); ?>
                    <?php echo $commander->getCommandButton('down', $primage->getId()); ?>
                </td>
				<td valign="middle" class="center"><img title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('image')); ?>" class="icon command cat_delete" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteImageDialog(<?php echo $primage->getId(); ?>);" /></td>
				</tr>
				<?php endforeach; ?>
			<?php endif; ?>
		</tbody>
    </table>
	<input type="hidden" id="del_image_id" name="del_img_id" value="0" />
</div>
<script type="text/javascript">
function deleteImageDialog(itemId)
{
	jQuery('#delete_image_dialog').dialog('open');
	jQuery('#delete_image_dialog').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('delete')).' '.$txt->getWord('image'); ?>': function() 
			{
				jQuery('#del_image_id').val(itemId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}
</script>
<div id="delete_image_dialog" title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('image')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete').' '.$txt->getWord('image')); ?></p>
</div>